/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package View;

import java.awt.BorderLayout;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Observable;
import java.util.Observer;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;

/**
 *
 * @author kenneth
 */
public class InfoArea extends JPanel implements Observer {
    
    JTextArea infoArea;
    JScrollPane infoWrap;
    
    public InfoArea() {
        infoArea = new JTextArea();
        infoArea.setEnabled(false);
        infoWrap = new JScrollPane(infoArea);
        infoArea = new JTextArea();
        infoArea.setEnabled(false);
        infoWrap = new JScrollPane(infoArea);
        this.setLayout(new BorderLayout());
        this.add(infoWrap, BorderLayout.CENTER);
    }
    
    @Override
    public void update(Observable o, Object o1) {
        Calendar currentDate = Calendar.getInstance(); 
        SimpleDateFormat formatter= new SimpleDateFormat("HH:mm:ss"); 
        String timeNow = formatter.format(currentDate.getTime());
        infoArea.append(timeNow + ": " + (String) o1 + "\n");
        infoArea.setCaretPosition(infoArea.getDocument().getLength());
    }
    
}
